import 'package:my_flutter_demo/exports.dart';
import 'package:my_flutter_demo/pages/textField_demo_page.dart';
import 'text_demo_page.dart';
import 'button_demo_page.dart';
import 'image_demo_page.dart';
import 'checkbox_demo_page.dart';

class BaseWidgetPage extends StatelessWidget{
  final HomeItem item;
  const BaseWidgetPage({Key? key,required this.item}) : super(key: key);
  static const List<String> listTitles = ['Text','Button','Image','TextField','Checkbox','Switch','Radio'];

  void tapAction(BuildContext context, String tag){
    if(tag == 'Text'){
      xx_push(context, const TextDemoPage());
    }else if (tag == 'Button'){
      xx_push(context, const ButtonDemoPage());
    }else if (tag == 'Image'){
      xx_push(context, const ImageDemoPage());
    }else if (tag == 'TextField'){
      xx_push(context, const TextFieldDemoPage());
    }else if (tag == 'Checkbox'){
      xx_push(context, const CheckboxDemoPage());
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(item.title),
      ),
      body: ListView.builder(
        itemCount: listTitles.length,
        itemBuilder: (context,index){
          String title = listTitles[index];
          return ListTile(
            leading: Icon(Icons.ac_unit),
            title: Text(title),
            onTap:(){
              tapAction(context, title);
            },
            trailing: const Icon(Icons.arrow_forward_ios),
          );
        },
      ),
    );
  }

}